package org.simple.framework.data.jpa.repository;

import org.simple.framework.data.entity.Identifiable;
import org.simple.framework.data.jpa.query.JpaQuerySpecification;
import org.simple.framework.data.query.BaseQuery;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.support.JpaEntityInformation;
import org.springframework.data.jpa.repository.support.QuerydslJpaRepository;

import jakarta.persistence.EntityManager;
import java.io.Serializable;
import java.util.List;

/**
 * 项目名称：simple-framework
 * 类名称：SimpleJpaModelRepository
 * 类描述：SimpleJpaModelRepository
 * 创建时间：2018/9/7
 *
 * @author sisyphus   (E-mail:1620657419@qq.com)
 * @version v1.0
 */
public class SimpleJpaModelRepository<E extends Identifiable<ID>, ID extends Serializable>
        extends QuerydslJpaRepository<E, ID> implements JpaModelRepository<E, ID> {

    public SimpleJpaModelRepository(JpaEntityInformation<E, ID> entityInformation, EntityManager entityManager) {
        super(entityInformation, entityManager);
    }

    @Override
    public List<E> findAll(BaseQuery<E> query) {
        return findAll(new JpaQuerySpecification<>(query));
    }

    @Override
    public Page<E> findAll(BaseQuery<E> query, Pageable pageable) {
        return findAll(new JpaQuerySpecification<>(query), pageable);
    }

}

